<!doctype html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>高级检索页面</title>
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css"/>
    <script src="/static/js/common/common.js" type="text/javascript"></script>
    <link href="/webjars/miniui/css/demo.css" rel="stylesheet" type="text/css"/>
    <link href="/static/css/default.css" rel="stylesheet" type="text/css"/>
    <link href="/static/js/bootstrap-4.4.1-dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="/static/js/azbj/search/search.js"></script>

    <style>
        body {
            padding-left: 0.5%;
            padding-right: 0.5%;
            padding-top: 0.5%;
            /*font-size: 14px;*/
        }
        label{
            margin-bottom: 0rem;
        }
        #table1,#azbjqkshow,#dataTable{
             border-collapse: separate;
            padding: 1.5%;
         }

        #jsdl{
            overflow: hidden;
            padding: 0;
            margin: 0;
        }
        #jsdl>li{
            padding: 0;
            margin: 0;
            float: left;
            width: 33.33%;
            height: 30px;
            line-height: 26px;
            box-sizing: border-box;
            border: 1px solid #dfdfdf;
            color: #4A89FD;
            text-align: center;
            list-style: none;
            cursor: pointer;
        }
        #jsdl>li.active{
            background: #4A89FD;
            border-color: #4A89FD;
            color: #fff;
        }
        .typeTitle{
            font-weight: bolder;
            display: inline-block;
            font-size: 14px;
            line-height: 15px;
            border-left:2px solid #4A89FD;
            color: #4A89FD;
            margin-left: 8px;
            padding-left: 8px;
        }
    </style>
</head>
<body>
<div class="mini-splitter" allowResize="false" handlerSize="10" style="width:100%;height:100%;">
    <div size="35%" minSize="456px" style="overflow: auto;">
        <ul id="jsdl">
            <li data-type="1" class="active" onclick="JsdlValuechanged(1)">预安置帮教人员</li>
            <li data-type="2" onclick="JsdlValuechanged(2)">安置帮教对象</li>
            <li data-type="3" onclick="JsdlValuechanged(3)">解除安置帮教对象</li>
        </ul>
        <div class="mini-fit" style="margin-bottom: 45px;">
            <input id="scopeModule" class="mini-hidden"/>
            <input id="azbjqk" name="azbjqk" class="mini-hidden"/>
            <table id="table1" width="100%" cellpadding="5" cellspacing="0">
                <#--<tr>
                    <td align="right" width="120px">检索大类：</td>
                    <td>
                        <input id="jsdl" style="width: 140px" class="mini-combobox" textField="name" valueField="id" emptyText="请选择..." onvaluechanged="JsdlValuechanged()"
                               data="[{ id: 1, name: '预安置帮教人员' },{ id: 2, name: '安置帮教对象' },{ id: 3, name: '解除安置帮教对象' }]"/>
                    </td>
                </tr>-->
                <tr>
                    <td width="130px" align="right">时间范围：</td>
                    <td>
                        <input id="sjfwstart" property="editor"  style="width: 140px" class="mini-datepicker scopeModule"  emptyText="开始日期"/>
                        <input id="sjfwend" property="editor" style="width: 140px" class="mini-datepicker scopeModule"  emptyText="结束日期"/>

                    </td>
                </tr>
                <tr>
                    <td  align="right">地域范围：</td>
                    <td>
                        <input showNullItem="true" id = "nativepro1"  style="width:140px;" class="mini-combobox scopeModule"  emptyText = "省"   textfield="codeName" valueField="codeId"
                                onclick="onRegionClick('nativepro1')" onvaluechanged = "onRegionChanged('nativepro1')"/>
                        <input showNullItem="true" id = "nativecity1" style="width: 140px" class="mini-combobox scopeModule"   emptyText = "市"   textfield="codeName" valueField="codeId"
                                onclick="onRegionClick('nativecity1')" onvaluechanged = "onRegionChanged('nativecity1')"/>
                        <input showNullItem="true" id = "nativecou1"  style="width: 140px" class="mini-combobox scopeModule"   emptyText = "区县"   textfield="codeName" valueField="codeId"
                                onclick="onRegionClick('nativecou1')"  onvaluechanged = "onRegionChanged('nativecou1')"/>
                        <input showNullItem="true" id = "nativevill1"  style="width: 140px" class="mini-combobox scopeModule"   emptyText = "乡镇"
                                textfield="codeName" valueField="codeId"onclick="onRegionClick('nativevill1')"/>
                    </td>
                </tr>
                <tr style="background: #F3F7FF">
                    <td><span class="typeTitle">基本情况</span></td>
                    <td align="right">
                        <input id="jbqkButton" class="mini-radiobuttonlist" textField="name" valueField="id" name="scope"
                               data="[{ id: 'AND', name: '并且' },{ id: 'OR', name: '或者' },{ id: 'NOT', name: '不含' }]"/>
                    </td>
                </tr>
                <tr>
                    <td  align="right">姓名：</td>
                    <td>
                        <input id="pname" style="width: 140px" class="mini-textbox jbqkButton"/>
                    </td>
                </tr>
                <tr>
                    <td  align="right">服刑单位：</td>
                    <td>
                        <input id="pdanwei" style="width: 140px" class="mini-combobox jbqkButton" textField="name" valueField="id" emptyText="请选择..."
                               showNullItem="true"  url="/azbj/solrsearch/solr/getJailList"/>
                    </td>
                </tr>
                <tr>
                    <td  align="right">户籍类别：</td>
                    <td>
                        <input id="hktype" style="width: 140px" class="mini-combobox jbqkButton" textField="codeName" valueField="codeId" emptyText="请选择..."
                               showNullItem="true"   url="/azbj/getCodeDetail/?codeType=68&codeId=-1"/>
                    </td>
                </tr>
                <tr>
                    <td  align="right">性别：</td>
                    <td>
                        <input id="sex" style="width: 140px" class="mini-combobox jbqkButton" textField="codeName" valueField="codeId" emptyText="请选择..."
                               showNullItem="true" url="/azbj/getCodeDetail/?codeType=2_2&codeId=-1"/>
                    </td>
                </tr>
                <tr>
                    <td  align="right">民族：</td>
                    <td>
                        <input id="nationality" style="width: 140px" class="mini-combobox jbqkButton" textField="codeName" valueField="codeId" emptyText="请选择..."
                               showNullItem="true" url="/azbj/getCodeDetail/?codeType=2_4&codeId=-1"/>
                    </td>
                </tr>
                <tr>
                    <td  align="right">农村户籍：</td>
                    <td>
                        <input id="village" class="mini-radiobuttonlist jbqkButton"
                               data="[{ id: 1, name: '是' },{ id: 2, name: '否' }]"  textField="name" valueField="id"/>
                    </td>
                </tr>
                <tr>
                    <td  align="right">户籍地：</td>
                    <td>
                        <input showNullItem="true" id="nativepro" name="nativepro" class="mini-combobox jbqkButton"  emptyText="省"
                               textfield="codeName" valueField="codeId" style="width: 140px;"
                               onclick="onDeptChanged('nativepro')" onvaluechanged="onValueChanged('nativepro')"/>
                        <input showNullItem="true" id="nativecity" name="nativecity" class="mini-combobox jbqkButton"  emptyText="市"
                               textfield="codeName" valueField="codeId" onclick="onDeptChanged('nativecity')"
                               onvaluechanged="onValueChanged('nativecity')" style="width: 140px;"/>
                        <input showNullItem="true" id="nativecou" name="nativecou" class="mini-combobox jbqkButton"  emptyText="区县"
                               textfield="codeName" valueField="codeId" onclick="onDeptChanged('nativecou')"
                               onvaluechanged="onValueChanged('nativecou')" style="width: 140px;"/>
                        <input showNullItem="true" id="nativevill" name="nativevill" class="mini-combobox jbqkButton" emptyText="乡镇" style="width: 140px;"
                               textfield="codeName" valueField="codeId"onclick="onDeptChanged('nativevill')"/>
                    </td>
                </tr>
                <tr style="background: #F3F7FF">
                    <td><span class="typeTitle">服刑情况</span></td>
                    <td align="right">
                        <input id="fxqkButton" class="mini-radiobuttonlist" textField="name" valueField="id" name="jbqk"
                               data="[{ id: 'AND', name: '并且' },{ id: 'OR', name: '或者' },{ id: 'NOT', name: '不含' }]"/>
                    </td>
                </tr>
                <tr>
                    <td  align="right">犯罪类型：</td>
                    <td>
                        <input id="fzlx" style="width: 140px" class="mini-combobox fxqkButton" textField="codeName" valueField="codeId" emptyText="请选择..."
                               showNullItem="true" url="/azbj/inmates/syscode?codeType=2_12&pCodeId=-1"/>
                    </td>
                </tr>
                <tr>
                    <td  align="right">刑期范围：</td>
                    <td>
                        <input id="pritime" style="width: 140px" class="mini-combobox fxqkButton" textField="codeName" valueField="codeId" emptyText="请选择..."
                               showNullItem="true"  url="/azbj/getCodeDetail/?codeType=2_14&codeId=-1"/>
                    </td>
                </tr>
                <tr>
                    <td  align="right">累惯犯：</td>
                    <td>
                        <input id="precri" class="mini-radiobuttonlist fxqkButton"
                               data="[{ id: 1, name: '是' },{ id: 2, name: '否' }]"  textField="name" valueField="id"/>
                    </td>
                </tr>
                <tr>
                    <td  align="right">附加刑：</td>
                    <td>
                        <input id="addpenalty" style="width: 140px" class="mini-combobox fxqkButton" textField="codeName" valueField="codeId" emptyText="请选择..."
                               showNullItem="true" url="/azbj/getCodeDetail/?codeType=1_8&codeId=-1"/>
                    </td>
                </tr>
                <tr>
                    <td  align="right">四史：</td>
                    <td>
                        <input class="mini-checkbox fxqkButton" text="袭警史" id="xijing">
                        <input class="mini-checkbox fxqkButton" text="逃脱史" id="taotuo">
                        <input class="mini-checkbox fxqkButton" text="吸毒史" id="drughis">
                        <input class="mini-checkbox fxqkButton" text="自杀史" id="zisha">
                    </td>
                </tr>
                <tr>
                    <td  align="right">五涉：</td>
                    <td>
                        <input class="mini-checkbox fxqkButton" text="涉恐" id="shekong">
                        <input class="mini-checkbox fxqkButton" text="涉邪" id="shexie">
                        <input class="mini-checkbox fxqkButton" text="涉毒" id="shedu">
                        <input class="mini-checkbox fxqkButton" text="涉枪" id="sheqiang">
                        <input class="mini-checkbox fxqkButton" text="涉黑恶" id="shehei">
                    </td>
                </tr>
                <tr>
                    <td  align="right">三无：</td>
                    <td>
                        <input class="mini-checkbox fxqkButton" text="无家可归"  id="wujia">
                        <input class="mini-checkbox fxqkButton" text="无亲可投"  id="wuqin">
                        <input class="mini-checkbox fxqkButton" text="无业可就"  id="wuye">
                    </td>
                </tr>
                <tr>
                    <td  align="right">三假：</td>
                    <td>
                        <input class="mini-checkbox fxqkButton" text="假姓名"  id="jxm">
                        <input class="mini-checkbox fxqkButton" text="假身份"  id="jsf">
                        <input class="mini-checkbox fxqkButton" text="假住址"  id="jhj">
                    </td>
                </tr>
                <tr id="hcqk_tr" style="background: #F3F7FF">
                    <td><span class="typeTitle">核查情况</span></td>
                    <td align="right">
                        <input  id="hcqkButton" class="mini-radiobuttonlist" textField="name" valueField="id" name="fxqk"
                                data="[{ id: 'AND', name: '并且' },{ id: 'OR', name: '或者' },{ id: 'NOT', name: '不含' }]"/>
                    </td>
                </tr>
                <tr id="hczt_tr">
                    <td  align="right">核查状态：</td>
                    <td>
                        <input id="state" style="width: 140px" class="mini-combobox hcqkButton" textField="name" valueField="id" emptyText="请选择..." showNullItem="true"
                               data="[{ id: 1, name: '未核查' },{ id: 2, name: '等待核查' },{ id: 3, name: '核查成功' },{ id: 4, name: '核查失败' }]"/>
                    </td>
                </tr>
                <tr style="background: #F3F7FF">
                    <td><span class="typeTitle">衔接情况</span></td>
                    <td align="right">
                        <input id="xjqkButton" class="mini-radiobuttonlist" textField="name" valueField="id" name="hcqk"
                               data="[{ id: 'AND', name: '并且' },{ id: 'OR', name: '或者' },{ id: 'NOT', name: '不含' }]"/>
                    </td>
                </tr>
                <tr>
                    <td  align="right">衔接状态：</td>
                    <td>
                        <input id="flag" style="width: 140px" class="mini-combobox xjqkButton" textField="name" valueField="id" emptyText="请选择..." showNullItem="true"
                               data="[{ id: 1, name: '衔接成功' },{ id: 2, name: '衔接中' },{ id: 3, name: '衔接失败' },{ id: 4, name: '未衔接' },{ id: 5, name: '待衔接' }]"/>
                    </td>
                </tr>
                <tr>
                    <td  align="right">帮教对象类别：</td>
                    <td>
                        <input id="type" style="width: 140px" class="mini-combobox xjqkButton" textField="name" valueField="id" emptyText="请选择..."  showNullItem="true"
                               onvaluechanged="BjdxlbValuechanged()" data="[{ id: '01', name: '重点帮教对象' },{ id: '02', name: '一般帮教对象' }]"/>
                    </td>
                </tr>
                <tr id="yibanshow" style="display: none">
                    <td  align="right">衔接方式：</td>
                    <td>
                        <input id="yiban" style="width: 140px" class="mini-combobox xjqkButton" textField="codeName" valueField="codeId" emptyText="请选择..."
                               showNullItem="true"  url="/azbj/getCodeDetail/?codeType=1_44&codeId=-1"/>
                    </td>
                </tr>
                <tr id="zhongdianshow" style="display: none">
                    <td  align="right">衔接方式：</td>
                    <td>
                        <input id="zhongdian" style="width: 140px" class="mini-combobox xjqkButton" textField="codeName" valueField="codeId" emptyText="请选择..."
                               showNullItem="true" url="/azbj/getCodeDetail/?codeType=1_45&codeId=-1"/>
                    </td>
                </tr>
            </table>
            <table id="azbjqkshow" width="100%" cellspacing="0" cellpadding="5" style="display:none;">
                <tr style="background: #F3F7FF">
                    <td width="130px"><span class="typeTitle">安置帮教情况</span></td>
                    <td align="right">
                        <input id="azbjqkButton" class="mini-radiobuttonlist" textField="name" valueField="id" name="xjqk"
                               data="[{ id: 'AND', name: '并且' },{ id: 'OR', name: '或者' },{ id: 'NOT', name: '不含' }]"/>
                    </td>
                </tr>
                <tr>
                    <td  align="right">社会救助方式：</td>
                    <td>
                        <input  id="shehuijiuzhu"  style="width: 140px" class="mini-combobox azbjqkButton" textField="codeName" valueField="codeId" emptyText="请选择..."
                                showNullItem="true"  url="/azbj/getCodeDetail/?codeType=1_36&codeId=-1"/>
                    </td>
                </tr>
                <tr>
                    <td  align="right">安置方式：</td>
                    <td>
                        <input  id="anzhiqingkuang"  style="width: 140px" class="mini-combobox azbjqkButton" textField="codeName" valueField="codeId" emptyText="请选择..."
                                showNullItem="true" url="/azbj/getCodeDetail/?codeType=1_38&codeId=-1"/>
                    </td>
                </tr>
                <tr id="jcbj">
                    <td  align="right">解除帮教原因：</td>
                    <td>
                        <input id="jiechureason" style="width: 140px" class="mini-combobox azbjqkButton" textField="codeName" valueField="codeId" emptyText="请选择..."
                               showNullItem="true" url="/azbj/getCodeDetail/?codeType=3_10&codeId=-1"/>
                    </td>
                </tr>
            </table>
        </div>
        <div style="position: absolute;bottom: 0;line-height: 45px;width: 100%;border-top: 1px solid #dfdfdf;text-align: center;">
            <a class="mini-button"  plain="true" onclick="searchData(1,'savesql')">高级检索</a>
            <a class="mini-button"  plain="true" onclick="resetData()">重置</a>
        </div>
    </div>
    <div style="width: 100%;overflow: auto;">
        <div class="mini-fit" style="margin-bottom: 45px;">
            <table width="100%" id="dataTable" style="overflow: auto;"></table>
            <div class="data-empty" style="display: none">
                <img style="display:block;width: 30%;margin: 20% auto 5%;" src="/static/images/data-empty.png" alt="">
                <h4 style="text-align: center">暂无相关数据...</h4>
            </div>
        </div>
        <div style="position: absolute;bottom: 0;height: 45px;width: 100%;box-sizing: border-box;padding-top: 5px;overflow: hidden;border-top: 1px solid #dfdfdf;">
            <div id="paginationDiv" style="float: right;margin-right: 10px;">
                <ul class="pagination"></ul>
            </div>
            <div id="pageLine" style="float: left;font-size: 12px;display: none;;margin-left: 15px;line-height: 35px;">
                共78条记录，共8页,第1页
            </div>
        </div>
    </div>
</div>


<script type="text/javascript">
    mini.parse();

    var nativepro1 = mini.get("nativepro1");
    var nativecity1 = mini.get("nativecity1");
    var nativecou1 = mini.get("nativecou1");
    var nativevill1 = mini.get("nativevill1");

    var nativepro = mini.get("nativepro");
    var nativecity = mini.get("nativecity");
    var nativecou = mini.get("nativecou");
    var nativevill = mini.get("nativevill");

    var azqk=document.getElementById("azbjqkshow");
    var hcqk_tr=document.getElementById("hcqk_tr");
    var hczt_tr=document.getElementById("hczt_tr");
    var zhongdianshow=document.getElementById("zhongdianshow");
    var yibanshow=document.getElementById("yibanshow");
    var zhongdian=mini.get("zhongdian");
    var yiban=mini.get("yiban");

    var sjfwstart=mini.get("sjfwstart");
    var sjfwend=mini.get("sjfwend");

    //当前页码
    var pageNum = 1;
    //总页数
    var pageSize = 0;
    //每页显示数量
    var eachPge = 10;

    //检索类别
    var searchType=1;

    //衔接状态
    var xjstate=mini.get("flag");


    searchData(1,'savesql');
    //控制安置情况的显示
    function JsdlValuechanged(jsdlvalue) {
        resetData();
        xjstate.setValue("");
        $('#jsdl>li').removeClass('active');
        $('#jsdl>li').eq(jsdlvalue-1).addClass('active');
        searchData(1,'savesql');
        // var jsdlvalue=jsdl.getValue();
        if(jsdlvalue==2 || jsdlvalue==3){
            //动态设置衔接状态的值
            xjstate.setData([{ id: 0, name: '已衔接' },{ id: 1, name: '未衔接' }]);
            //安置情况置空
            var azbjqktable = new mini.Form("azbjqkshow")
            var azbjqkFields=azbjqktable.getFields();
            $(azbjqkFields).each(function(i,item){
                item.setValue("");
            });
            if(jsdlvalue==3){//解除安帮才显示解除帮教原因
                document.getElementById("jcbj").style.display = "table-row";
            }else{
                document.getElementById("jcbj").style.display = "none";
            }
                azqk.style.display = "table";
            hcqk_tr.style.display = "none";
            hczt_tr.style.display = "none";
        }else{
            xjstate.setData([{ id: 1, name: '衔接成功' },{ id: 2, name: '衔接中' },{ id: 3, name: '衔接失败' },{ id: 4, name: '未衔接' },{ id: 5, name: '待衔接' }]);
            azqk.style.display = "none";
        }
    }
    //控制衔接方式的显示
    function BjdxlbValuechanged() {
        zhongdian.setValue("");
        yiban.setValue("");
        var typevalue=mini.get("type").getValue();
        if(typevalue=='01'){
            zhongdianshow.style.display = "table-row";
            yibanshow.style.display = "none";
        }else{
            yibanshow.style.display = "table-row";
            zhongdianshow.style.display = "none";
        }
    }
    /**
     * 地域范围
     * @param e
     */
    function onRegionClick(e) {
        if("nativepro1" == e){
            // ownpro.setValue("");
            var url =  "/azbj/getCodeDetail/?codeType=2_1&codeId=-1";
            nativepro1.load(url);
            // ownpro.select(0);
        }
        if("nativecity1" == e){
            var codeId = nativepro1.getValue();
            // owncity.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=" + codeId;
            if(codeId){
                nativecity1.load(url);
            }else{
                nativecity1.setData(null)
            }
            // owncity.select(0);
        }

        if("nativecou1" == e) {
            var codeId = nativecity1.getValue();
            // owncou.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=" + codeId;
            if(codeId){
                nativecou1.load(url);
            }else{
                nativecou1.setData(null)
            }
            // owncou.select(0);
        }

        if("nativevill1" == e){
            var parent_code = nativecou1.getValue();
            // ownsfs.setValue("");
            var url = "/azbj/getCodeDetail?codeType=2_1&codeId=" + parent_code;
            nativevill1.load(url);
            // ownsfs.select(0);
        }
    }

    function onRegionChanged(e) {
        if("nativepro1" == e){
            nativecity1.setValue("");
            nativecou1.setValue("");
            nativevill1.setValue("");
        }

        if("nativecity1" == e){
            nativecou1.setValue("");
            nativevill1.setValue("");
        }

        if("nativecou1" == e) {
            nativevill1.setValue("");
        }

    }
    /**
     * 户籍地址
     * @param e
     */
    function onDeptChanged(e) {
        if ("nativepro" == e) {
            // nativepro.setValue("");
            var url =  "/azbj/getCodeDetail/?codeType=2_1&codeId=-1";
            nativepro.setUrl(url);
            // nativepro.select(0);
        }
        if ("nativecity" == e) {
            var codeId = nativepro.getValue();
            // nativecity.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=" + codeId;
            if(codeId){
                nativecity.setUrl(url);
            }else{
                nativecity.setData(null)
            }
            // nativecity.select(0);
        }

        if ("nativecou" == e) {
            var codeId = nativecity.getValue();
            // nativecou.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=" + codeId;
            if(codeId){
                nativecou.setUrl(url);
            }else{
                nativecou.setData(null)
            }
            // nativecou.select(0);
        }

        if ("nativevill" == e) {
            var parent_code = nativecou.getValue();
            // nativevill.setValue("");
            var url = "/azbj/getCodeDetail?codeType=2_1&codeId=" + parent_code;
            nativevill.setUrl(url);
            // nativevill.select(0);
        }
    }

    function onValueChanged(e) {
        if ("nativepro" == e) {
            nativecity.setValue("");
            nativecou.setValue("");
            nativevill.setValue("");
        }
        if ("nativecity" == e) {
            nativecou.setValue("");
            nativevill.setValue("");
        }
        if ("nativecou" == e) {
            nativevill.setValue("");
        }
    }

    //高级检索查询数据
    function searchData(pNum,savesql) {
        var flag=true;
        //分页查询不用再执行校验和保存检索条件
        if(savesql){
            //验证检索大类
            var jsdlvalue=$('#jsdl>li.active').data('type');
            if(!jsdlvalue){
                mini.alert("请选择检索大类的类别");
                return;
            }
            searchType=jsdlvalue;
            //验证时间
            var start = sjfwstart.getText();
            var end = sjfwend.getText();
            if(start && end && start>end){
                mini.alert("结束日期不能小于开始日期，请重新选择");
                return;
            }
            //拼接sql
            var sqltext=joinCondition();
            flag=saveSqltext(sqltext);
        }
        if(flag){
            var data = {};
            //获取拼接的sql
            data.start = (pNum - 1) * eachPge;
            data.pageSize = eachPge;
            data.searchType = searchType;
            data.type = 2;
            var json = mini.encode(data);
            $.ajax({
                url: "/azbj/solrsearch/solr/advanceSearch",
                type: "post",
                data:{data: json},
                async: false,
                success: function (result) {
                    pageSize = Math.ceil(result.total/eachPge);
                    autoTable(result.data);
                    autoPage(pNum);
                    $("#pageLine").text(" 共"+result.total+"条记录，共"+pageSize+"页,第"+pageNum+"页");
                    document.getElementById("pageLine").style.display = "block";
                }
            });
        }
    }

    function autoTable(dataList) {
        $("#dataTable").html("");
        var tr = '<tr>';
        if(dataList.length){
            $(".data-empty").hide();
            for (var i = 0; i < dataList.length; i++) {
                var prinumTemp="\'"+dataList[i].prinum+"\'";
                tr += '' +
                    '       <td>\n' +
                    '               <div style="margin: 2.5% 3% 3%;">\n' +
                    '                    <img src="/azbj/search/queryImageData?url=' + encodeURI(dataList[i].fileurl) + '" width="75" height="100" style="border: 0px solid #ccc;float: left;cursor: pointer" onclick = "toViewHjqc(' + (prinumTemp?prinumTemp:'')  + ')" > \n' +
                    '                    <div style="margin-left: 74px;height: 100px;padding-left:3%;text-align: left;border:1px solid #dfdfdf"> \n' +
                    '                        <span style="font-size: 14px;cursor: pointer" onclick = "toViewHjqc(' + (prinumTemp?prinumTemp:'')  + ')" >' + (dataList[i].pname?dataList[i].pname:'') + '</span><span style="font-size: 10px">/' + dataList[i].xb + '</span><br> \n' +
                    '                        <span  class="gray">身份证：</span><span  class="black">' + (dataList[i].idnum?dataList[i].idnum:'')  + '</span><br> \n' +
                    '                        <span  class="gray">服刑单位：</span><span  class="black">' + (dataList[i].pdanweiname?dataList[i].pdanweiname:'') + '</span><br>\n' +
                    '                        <span  class="gray">释放时间：</span><span  class="black">' + (dataList[i].sfsj?dataList[i].sfsj:'') + '</span><br> \n' +
                    '                        <span  class="gray">户籍信息：</span><span title="'+(dataList[i].hjdz?dataList[i].hjdz:'')+'" style="display:inline-block;width: 73%;vertical-align: sub;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" class="black">' + (dataList[i].hjdz?dataList[i].hjdz:'') + '</span><br> \n' +
                    '                    </div>\n' +
                    '                </div>\n' +
                    '       </td>\n';

                if (i % 2 == 1) {
                    tr += '</tr>';
                    tr += '<tr>';
                }  else if (i == (dataList.length - 1)) {
                    tr += '</tr>';
                    // var trObj = $(tr);
                    // trObj.appendTo($("#dataTable"));
                    // tr = '<tr>';
                }
            }
            $("#dataTable").html(tr);
        }else{
            $(".data-empty").show()
        }
    }

    //生成分页栏
    function autoPage(pNum) {
        pageNum = pNum;
        $("#paginationDiv ul").html("");
        if (pageSize < 5) {
            $(autoPageNum(1, pageSize, pageNum)).appendTo($("#paginationDiv ul"));
        } else if (pageNum < 3 && pageSize >= 5) {
            $(autoPageNum(1, 5, pageNum)).appendTo($("#paginationDiv ul"));
        } else if (pageNum >= pageSize - 2) {
            $(autoPageNum(pageSize - 4, pageSize, pageNum)).appendTo($("#paginationDiv ul"));
        } else {
            $(autoPageNum(pageNum - 2, pageNum + 2, pageNum)).appendTo($("#paginationDiv ul"));
        }

    }

    function autoPageNum(pageStart, pageEnd, pNum) {
        var pages = '';
        var first = '<li class="page-item" onclick="toMovePage(1)"><a class="page-link" href="#">&lt;&lt;</a></li>';
        var pre = '<li class="page-item" onclick="toMovePage(2)"><a class="page-link" href="#">&lt;</a></li>';
        var next = '<li class="page-item" onclick="toMovePage(3)"><a class="page-link" href="#">&gt;</a></li>';
        var last = '<li class="page-item" onclick="toMovePage(4)"><a class="page-link" href="#">&gt;&gt;</a></li>';
        for (var i = pageStart; i < pageEnd + 1; i++) {
            if (pNum == i) {
                pages += '<li class="page-item active "  onclick="searchData(' + i + ')"><a class="page-link" href="#">' + i + '</a></li>';
            } else {
                pages += '<li class="page-item"  onclick="searchData(' + i + ')"><a class="page-link" href="#">' + i + '</a></li>';
            }
        }
        return first + pre + pages + next + last;
    }

    //点击页码跳转
    function toMovePage(e) {
        if (e == 1) {
            searchData(1);
        } else if (e == 2) {
            searchData(pageNum > 1 ? (pageNum - 1) : pageNum);
        } else if (e == 3) {
            searchData(pageNum < pageSize ? (pageNum + 1) : pageNum);
        } else if (e == 4) {
            searchData(pageSize);
        }
    }

    function saveSqltext(sqltext) {
        var flag = false;
        var data = {};
        data.sqltext=sqltext;
        data.type = 2;
        var json = mini.encode(data);
        $.ajax({
            url:"/azbj/solrsearch/solr/saveSqltext",
            type:"post",
            data:{data: json},
            async: false,
            success:function(result){
                if(result.code==1){
                    flag = true;
                }else{
                    mini.alert("操作失败！");
                }
            },
            error:function(){
                mini.alert("操作失败！");
            }
        });
        return flag;
    }

    //条件重置
    function resetData() {
        //清空table1值
        var table1 = new mini.Form("table1")
        var table1Fields=table1.getFields();
        $(table1Fields).each(function(i,item){
            item.setValue("");
        });
        //清空安置帮教情况值
       var azbjqktable = new mini.Form("azbjqkshow")
        var azbjqkFields=azbjqktable.getFields();
        $(azbjqkFields).each(function(i,item){
            item.setValue("");
        });
    }

   //拼接sql条件
    function joinCondition() {
        var data = {};
        //范围模块
        data.scope=fwmodulesql("scopeModule");
        //基本情况
        data.jbqk=joinmodulesql("jbqkButton");
        //服刑情况
        data.fxqk=joinmodulesql("fxqkButton");
        //核查情况
        data.hcqk=joinmodulesql("hcqkButton");
        //衔接情况
        data.xjqk=joinmodulesql("xjqkButton");
        //检索大类是安置帮教和解除安帮要加安置情况
        var jsdlvalue=$('#jsdl>li.active').data('type');
        if(jsdlvalue && (jsdlvalue!=1)){
           data.azbjqk=azbjqkmodulesql("azbjqkButton");
        }
        var dataStr = "";
        for(var key in data){
            if(data[key]!=""){
                var controls=mini.getChildControls(document.body);
                $(controls).each(function(i,item){
                   var name= $(this).attr("name");
                   if(name==key){
                       var id= $(this).attr("id");
                       var value=mini.get(id).getValue();
                       //根据关系值判断拼接 AND或者OR
                       if(value!='OR'){
                           dataStr += "(" + data[key] + ") AND ";
                       }else{
                           dataStr += "(" + data[key] + ") OR ";
                       }
                       return false; //跳出所有循环
                   }
                })
            }
        }
        dataStr = dataStr.substr(0,dataStr.length-4);
        return dataStr;
    }

    //模块拼接sql
    function joinmodulesql(classStr) {
        var gxvalue=mini.get(classStr).getValue();
        var modulesql = "";
        $("." + classStr ).each(function () {
            var id = $(this).attr("id");
            //处理四史、五涉、三无、三假
            if(classStr=='fxqkButton'){
                var classvalue = $(this).attr("class");
                if(classvalue=='mini-checkbox fxqkButton'){
                    if(mini.get(id).getChecked()==false){//复选框没选中不拼值
                        return true;//跳出当前循环
                    }
                }
            }
            var value=mini.get(id).getValue();
            if (value) {
                if(gxvalue=='NOT'){//‘非’关系单独处理
                    modulesql+="*:* "+ "-" +id+":"+value +" AND ";
                }else{
                    modulesql+= id+":"+value +" AND ";
                }
            }
        });
        modulesql = modulesql.substr(0,modulesql.length-5);
        return modulesql;
    }

    //单独处理安置帮教情况 安置帮教人员类别、社会救助方式和安置方式要模糊匹配
    function azbjqkmodulesql(classStr) {
        var gxvalue=mini.get(classStr).getValue();
        var modulesql = "";
        $("." + classStr ).each(function () {
            var id = $(this).attr("id");
            var value=mini.get(id).getValue();
            if (value) {
                if(id=='xusertype' || id=='shehuijiuzhu' || id=='anzhiqingkuang'){//模糊匹配处理
                    if(gxvalue=='NOT'){//‘非’关系单独处理
                        modulesql+="*:* "+ "-"+id+":*"+value+"*"+" AND ";
                    }else{
                        modulesql+= id+":*"+value+"*" +" AND ";
                    }
                }else{
                    if(gxvalue=='NOT'){//‘非’关系单独处理
                        modulesql+="*:* "+ "-" +id+":"+value +" AND ";
                    }else{
                        modulesql+= id+":"+value +" AND ";
                    }
                }
            }
        });
        modulesql = modulesql.substr(0,modulesql.length-5);
        return modulesql;
    }

    //单独处理时间范围和地域范围
   function fwmodulesql(classStr) {
       var modulesql = "";
       $("." + classStr ).each(function () {
           var classvalue = $(this).attr("class");
           //处理时间范围
           if(classvalue.indexOf("mini-datepicker")>-1){
               var start = sjfwstart.getText();
               var end = sjfwend.getText();
               modulesql=start + end == "" ? "" : ("sjfw:[" + (start == "" ? " * " : (start + "T00:00:00Z")) + " TO " + (end == "" ? " * " : (end + "T23:59:59Z")) + "]")+" AND ";
           }else{
               var id = $(this).attr("id");
               var value=mini.get(id).getValue();
               if(value){
                   modulesql+= id+":"+value +" AND ";
               }
           }
       });
       modulesql = modulesql.substr(0,modulesql.length-5);
       return modulesql;
   }
</script>

</body>
</html>